package Controlador;

import java.sql.Connection;
import java.sql.DriverManager;

import javax.swing.JOptionPane;

public class MySQLConnection {

	public Connection conectar()

	{
		String usuario = "root";
		String password = "";
		String host = "localhost";
		String puerto = "3306";
		String database = "spaq";
		String driver = "com.mysql.jdbc.Driver";
		String ulrjdbc = "jdbc:mysql://" + host + ":" + puerto + "/" + database;

		Connection connection = null;
		try {
			Class.forName(driver).newInstance();
			connection = DriverManager
					.getConnection(ulrjdbc, usuario, password);

		} catch (Exception e) {
			JOptionPane.showMessageDialog(null,
					"No se puede establecer la conexion con la Base de Datos",
					"Error critico", JOptionPane.ERROR_MESSAGE);
		}

		return connection;
	}

}
